package cn.monkey.family.data.uc.user;

import cn.monkey.family.data.EntityMapper;
import cn.monkey.family.data.uc.user.role.UserRoleVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class UserMapper extends EntityMapper<UserDto, User, UserVo> {


    @Override
    @Mapping(target = "creator", source = "creatorId", qualifiedByName = "getUserIdAndNamePairFromId")
    @Mapping(target = "updater", source = "updaterId", qualifiedByName = "getUserIdAndNamePairFromId")
    public abstract UserVo toVo(User user);

    @Override
    public abstract User toEntity(UserDto userDto);

}
